package util;

import java.util.HashMap;
import java.util.Map;

//弹仓
public class Magazine {
    private Map<String, Integer> ammunition; // dbid,number

    public Magazine() {
        ammunition = new HashMap<>();
        ammunition.put("0", 100);
    }

    public String push() {
        for (String keyString : ammunition.keySet()) {
            if (ammunition.get(keyString) != 0) {
                int number = ammunition.get(keyString);
                number--;
                ammunition.put(keyString, number);
                return keyString;
            }
        }
        return null;
    }

    @Override
    public String toString() {
        return "Magazine [ammunition=" + ammunition + "]";
    }

}
